KeyboardEvent: key property 您所在的位置:网站首页 keydown keycode KeyboardEvent: key property

KeyboardEvent: key property

2023-10-20 19:45| 来源: 网络整理| 查看: 265

When the shift key is pressed, a keydown event is first fired, and the key property value is set to be the string Shift. As we keep holding this key, the keydown event does not continue to fire repeatedly because it produced no character key.

When key 2 is pressed, another keydown event is fired for this new key press, and the key property value for the event is set to be the string @ for the U.S keyboard type and " for the UK keyboard type, because of the active modifier shift key. The beforeinput and input events are fired next because a character key has been produced. As we keep holding the key, the keydown event continues to fire repeatedly and the KeyboardEvent.repeat property is set to true. The beforeinput and input events are fired repeatedly as well.

As we release the shift key, a keyup event is fired for it, and the key attribute value remains Shift. At this point, notice that the key property value for the repeating keydown event of the key 2 key press is now "2" because the modifier shift key is no longer active. The same goes for the InputEvent.data property of the beforeinput and input events.

As we finally release the key 2, a keyup event is fired but the key property will be set to the string value 2 for both keyboard layouts because the modifier shift key is no longer active.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有